class Player
	def play_turn(warrior)
		if warrior.health < 6
			simple_rest(warrior)
		else
			simple_attack(warrior)
		end
	end
	
	def simple_attack(warrior)
		directions = [:left,:right,:forward,:backward]
		stair = warrior.direction_of_stairs
		if warrior.feel(stair).enemy?
			#更多
			more = false
			directions.each{|item| 
			if item != stair && warrior.feel(item).enemy?
				warrior.bind!(item)
				more = true
				break
			end
			}
			if !more
				warrior.attack!(stair)
			end
		elsif warrior.look(stair)[0].to_s == "nothing"
			warrior.walk!(stair)
		else
			warrior.attack!(stair)
		end
	end
	
	def simple_rest(warrior)
		if !warrior.feel(:left).enemy? && !warrior.feel(:right).enemy? && !warrior.feel(:forward).enemy? && !warrior.feel(:backward).enemy?
			warrior.rest!
		elsif warrior.feel(:forward).empty?
			warrior.walk!
		elsif warrior.feel(:backward).empty?
			warrior.walk!(:backward)
		end
	end
 end
